package com.example.plantplacessummer2013;

import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;

/**
 * Everything general to all activities in our app. 
 * 
 * @author jonesbr
 *
 */
public class PlantPlacesActivity extends Activity {

	private static final int MENU_GPS_PLANT = 2;
	private static final int MENU_ADVANCED_SEARCH = 1;
	public static final String WEB_ROOT = "http://www.plantplaces.com";
	public static final String PLANT_DETAILS = "/perl/viewplantdetails.pl?plant_ID=";
	public static final String SOURCE = "source=mobile";
	public static final String WEB_DELIMITER = "&";
	public static final String RESULT = "RESULT";
	public static final String PLANT_RESULT = "PLANT_RESULT";

	public PlantPlacesActivity() {
		super();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		super.onCreateOptionsMenu(menu);
		
		// add a menu item.
		menu.add(0, MENU_ADVANCED_SEARCH, Menu.NONE, getString(R.string.advanced_search)).setAlphabeticShortcut('a');
		menu.add(0, MENU_GPS_PLANT, Menu.NONE, getString(R.string.mnuGPSAPlant)).setAlphabeticShortcut('g');
		
		menu.setQwertyMode(true);
		
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		super.onOptionsItemSelected(item);
		
		switch(item.getItemId()) {
		case MENU_ADVANCED_SEARCH:
			openAdvancedSearch();
			break;
		case MENU_GPS_PLANT:
			gpsAPlant();
			break;
		}
		return true;
	}

	private void gpsAPlant() {
		// TODO Auto-generated method stub
		Intent gpsIntent = new Intent(this, LocationActivity.class);
		startActivity(gpsIntent);
	}

	/**
	 * Open the Advanced Search Activity.
	 */
	private void openAdvancedSearch() {
		// TODO Auto-generated method stub
		Intent advancedSearchIntent = new Intent(this, AdvancedPlantSearch.class);
		startActivity(advancedSearchIntent);
		
	}

}